home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega Doom 1
/
Mega Doom 1.iso
/
editors
/
dmbsp
/
funcs.c
< prev
next >
Wrap
Text File
|
1994-04-11
|
985b
|
39 lines
/*- FUNCS.C ----------------------------------------------------------------*/
/*- terminate the program reporting an error -------------------------------*/
void ProgError( char *errstr, ...)
{
va_list args;
va_start( args, errstr);
printf( "\nProgram Error: *** ");
vprintf( errstr, args);
printf( " ***\n");
va_end( args);
exit( 5);
}
/*- allocate memory with error checking ------------------------------------*/
void *GetMemory( size_t size)
{
void *ret = malloc( size);
if (!ret)
ProgError( "out of memory (cannot allocate %u bytes)", size);
return ret;
}
/*- reallocate memory with error checking ----------------------------------*/
void *ResizeMemory( void *old, size_t size)
{
void *ret = realloc( old, size);
if (!ret)
ProgError( "out of memory (cannot reallocate %u bytes)", size);
return ret;
}
/*--------------------------------------------------------------------------*/